<?php

/**
 * @name: HOTN Sponsor
 * @author: HammerOnTheNail
 * @link: http://code.google.com/p/hotnsponsor/
 */

if (!defined('e107_INIT')) { exit; }

global $tp;
@include(e_PLUGIN."hotn_sponsor/languages/".e_LANGUAGE.".php");
@include(e_PLUGIN."hotn_sponsor/options.php");
include(e_PLUGIN."hotn_sponsor/hotn_sponsor_shortcodes.php");
if (file_exists(THEME."hotn_sponsor/hotn_sponsor_template.php"))
		include(THEME."hotn_sponsor/hotn_sponsor_template.php");
	else
		include(e_PLUGIN."hotn_sponsor/hotn_sponsor_template.php");
	
if (file_exists(THEME."hotn_sponsor/support.gif"))
		define("HOTN_SPONSOR_IMAGE",THEME."hotn_sponsor/support.gif");	
	elseif (file_exists(THEME."hotn_sponsor/support.png"))
		define("HOTN_SPONSOR_IMAGE",THEME."hotn_sponsor/support.png");	
	else
		define("HOTN_SPONSOR_IMAGE",e_PLUGIN."hotn_sponsor/images/support.png");

global $HOTN_SPONSOR_MONEY, $HOTN_SPONSOR_PERCENT;
$HOTN_SPONSOR_MONEY = 0;
$sql = new db;

$sql->db_Select("hotn_sponsor_money","*");
while ($row = $sql->db_Fetch())
{
	if ($row['hotn_sponsor_money_minus'] == '1')
			$HOTN_SPONSOR_MONEY -= $row['hotn_sponsor_money_money'];
		else
			$HOTN_SPONSOR_MONEY += $row['hotn_sponsor_money_money'];
}

$HOTN_SPONSOR_PERCENT = round($HOTN_SPONSOR_MONEY/$_HOTN_SPONSOR_OPTIONS['hotn_sponsor_options_max']*100);

$ns->tablerender(HOTN_SPONSOR_MENU_CAPTION, $tp->parseTemplate($HOTN_SPONSOR_MENU_TEMPLATE, false, $hotn_sponsor_shortcodes), 'hotn_sponsor');
?>